package com.ziyucoding.springboot.labs.mybatis.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ziyucoding.springboot.labs.mybatis.dataobject.UserInfoDO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.List;

/**
 * 用户 Mapper
 */
@Repository
public interface UserInfoMapper extends BaseMapper<UserInfoDO> {

    default UserInfoDO selectByUserName(@Param("userName") String userName) {
        return selectOne(new QueryWrapper<UserInfoDO>().eq("user_name", userName));
    }

    List<UserInfoDO> selectByIds(@Param("ids") Collection<Integer> ids);

    default IPage<UserInfoDO> selectPageByGender(IPage<UserInfoDO> page, @Param("gender") Integer gender) {
        return selectPage(page,
                new QueryWrapper<UserInfoDO>().eq("gender", gender));
    }

}
